<%@page import="by.epam.communalservices.entity.User"%>
<%@page import="by.epam.communalservices.dao.jdbc.JdbcDaoUser"%>
<%@page import="java.sql.Connection"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags/connect" prefix="connect"%>
<%@ taglib tagdir="/WEB-INF/tags/table" prefix="table"%>
<%@ taglib tagdir="/WEB-INF/tags/user" prefix="user"%>

<connect:isset/>
<connect:denny rules="admin,edit,user_edit" />


<user:edit id="${param.id}" login="${param.login}" 
				passw="${param.passw}" 
				delete="${param.delete}" 
				submit="${param.submit}"/>

<c:if test="${requestScope.message ne ''}">
	<p class='message'>
		<c:out value="${message}" />
	</p>
</c:if>
<c:if test="${param.delete gt 0}">
	<c:import url="/WEB-INF/pages/user_view.jsp"  />
</c:if>
<c:if test="${form}">
	<form method='POST' action='user_edit'>
		<table:body style='width:50%;'>
			<table:title span="4">
	   		<c:choose>
      			<c:when test="${param.id gt 0}">
      				Редактирование юзера
  				</c:when>
  				<c:otherwise>
      				Добавление юзера
  				</c:otherwise>
  			</c:choose>
			</table:title>

			<input name='id' value="${requestScope.user.id}" type="hidden">
			<tr id=c>
				<td colspan=2 class=t>Имя пользователя</td>
				<td colspan=2 class=t id=l>Пароль пользователя</td>
			</tr>
			<tr id=c>
				<td colspan=2 class=t ><input name='login' value="${requestScope.user.login}">
				</td>
				<td colspan=2 class=t id=l><input name='passw' value="${requestScope.user.passw}">
				</td>
			</tr>
			<tr id=n class=t>
				<td colspan=4 id=l>Права пользователя</td>
			</tr>
			<user:role id="${requestScope.user.id}" />
			<table:title span="4" down="yes">
	   		<input name='submit' value='save' type='submit'>
			</table:title>
		</table:body>
	</form>
</c:if>
